home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
016a
/
settime.zip
/
SETTIME.CPP
next >
Wrap
Text File
|
1991-10-01
|
1KB
|
34 lines
// **************************************************************************
// SETTIME.CPP
//
// Written By: Bob Marriott, ELAR Computer Systems
// Date: 09/30/91
//
// Description: Reads the CMOS Real Time clock and updates the BIOS Time
// of day count. This program should run on IBM AT's and
// compatibles, however no warrenty is implied or expressed.
// This Program is released to the PUBLIC DOMAIN by its
// author.
//
//***************************************************************************
#include <dos.h>
#define RTCLOCK 0x1a
int main(void)
{
struct time t; // record structure for system BIOS time call
union REGS regs; // record structure for interrupt call
regs.h.ah = 0x2; // Read Real Time Clock
int86(RTCLOCK, ®s, ®s); // get Time from CMOS real time clock
t.ti_hour = (regs.h.ch & 0xf) + (regs.h.ch >> 4)*10; // convert CMOS time
t.ti_min = (regs.h.cl & 0xf) + (regs.h.cl >> 4)*10; // from BCD to the
t.ti_sec = (regs.h.dh & 0xf) + (regs.h.dh >> 4)*10; // BIOS record struct
settime(&t); // set the BIOS time
};